#ifndef _PWM_H
#define _PWM_H

#define PWM_CLOCK           5 
//PWM Chanel
typedef enum YS_PWMChanel {
	PWM_CH0 = 0,
	PWM_CH1 = 1,
} YC_PWMChanel_e;

/**
    * @brief Pwm configure the parameter structure
    * 
    */
typedef struct {
	YC_PWMChanel_e channal;/*!< pwm channel select, 0: channel 0,  1:channel 1*/
	u8_t   outgpio;/*!< channel 1: gpio 5
				       channel 0 : gpio[3,4,6,7,18,19,20,21,22]*/
	u16_t pcnt;/*!< PWM channel positive pulse clock count*/
	u16_t ncnt;/*!< PWM channel npositive pulse clock count.
					PWM channel frequency = (48M/(PWM_pcnt+PWM_ncnt))Hz
					Duty ratio = (PWM_pcnt/(PWM_pcnt+PWM_ncnt))*100%*/
}PWM_Set;

  /** 
    * @brief initialized PWM Clock
    * @param no 
    * @return null
    */
void YC_PWMInitClock();

  /** 
    * @brief Close PWM clock
    * @param no 
    * @return null
    */
void YC_PWMCloseClock();

/** 
    * @brief configurate PWM 
    * @param PwmConfig :Pwm configure the parameter structure
    * @return null
    */ 
void YC_PWMConfig(PWM_Set *PwmConfig);

/** 
    * @brief Enable PWM channel
    * @param PWMChSel : PWM channel select
    * @return null
    */
void YC_PWMEnableChanel(YC_PWMChanel_e PWMChSel);

/** 
    * @brief Disable PWM Channel
    * @param PWMChSel : PWM channel select
    * @return null
    */
void YC_PWMDisableChanel(YC_PWMChanel_e PWMChSel);

/** 
    * @brief Open PWM output pin
    * @param PWMChSel : PWM channel select
    * @param gpio : PWM channel IO select
    * @return null
    * PWMChSel has two effective value PWM_CH0 or PWM_CH1
    * gpio :if PWMChSel is equal to PWM_CH0, effective value of gpio are 3,4,6,7,18,19,20,21,22.
    *		if PWMChSel is equal to PWM_CH1, effective value of gpio are 5.
    */
void YC_PWMOpenChanel(YC_PWMChanel_e PWMChSel, u8_t gpio);

/** 
    * @brief Close PWM output pin
    * @param gpio : PWM channel IO select
    * @return null
    */
void YC_PWMCloseChanel(u8_t gpio);
#endif

